package com.ruoyi.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Cv;
import com.ruoyi.system.service.ICvService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 存放职位投递简历信息管理Controller
 * 
 * @author ruoyi
 * @date 2024-05-22
 */
@RestController
@RequestMapping("/system/cv")
public class CvController extends BaseController
{
    @Autowired
    private ICvService cvService;

    /**
     * 查询存放职位投递简历信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:cv:list')")
    @GetMapping("/list")
    public TableDataInfo list(Cv cv)
    {
        startPage();
        List<Cv> list = cvService.selectCvList(cv);
        return getDataTable(list);
    }

    /**
     * 导出存放职位投递简历信息管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:cv:export')")

    @PostMapping("/export")
    public void export(HttpServletResponse response, Cv cv)
    {
        List<Cv> list = cvService.selectCvList(cv);
        ExcelUtil<Cv> util = new ExcelUtil<Cv>(Cv.class);
        util.exportExcel(response, list, "存放职位投递简历信息管理数据");
    }

    /**
     * 获取存放职位投递简历信息管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:cv:query')")
    @GetMapping(value = "/{jobId}")
    public AjaxResult getInfo(@PathVariable("jobId") Long jobId)
    {
        return success(cvService.selectCvByJobId(jobId));
    }

    /**
     * 新增存放职位投递简历信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:cv:add')")

    @PostMapping
    public AjaxResult add(@RequestBody Cv cv)
    {
        return toAjax(cvService.insertCv(cv));
    }

    /**
     * 修改存放职位投递简历信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:cv:edit')")

    @PutMapping
    public AjaxResult edit(@RequestBody Cv cv)
    {
        return toAjax(cvService.updateCv(cv));
    }

    /**
     * 删除存放职位投递简历信息管理
     */
    @PreAuthorize("@ss.hasPermi('system:cv:remove')")

	@DeleteMapping("/{jobIds}")
    public AjaxResult remove(@PathVariable Long[] jobIds)
    {
        return toAjax(cvService.deleteCvByJobIds(jobIds));
    }
}
